package net.zdreamer.shunyi.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import net.zdreamer.shunyi.R;
import net.zdreamer.shunyi.myview.HorizontalListView;
import net.zdreamer.shunyi.utils.ImageUtil;
import net.zdreamer.shunyi.utils.ListUtils.GuangChangInfos.GuangChangInfo;
import net.zdreamer.shunyi.utils.ListUtils.PhotolistInfos;
import net.zdreamer.shunyi.utils.ViewHolder;

import java.util.List;

/**
 * Created by Admin on 2015/1/5.
 */
public class GuangChangAdapter extends MyBaseAdapter<GuangChangInfo> {

    private ImageView photo, images;
    private TextView name, address, time, titletext, textcontent;
    private HorizontalListView photolist;
    private Context context;
    private PhotoListAdapter mAdapter;

    public GuangChangAdapter(Context context, List<GuangChangInfo> list, int res) {
        super(context, list, res);
        this.context = context;
    }

    @Override
    protected View getView(int position, View convertView, ViewGroup parent, GuangChangInfo value) {
        photo = (ImageView) ViewHolder.get(convertView, R.id.guangchangicon);
        //  photo.setImageBitmap(ImageUtil.toRoundBitmap(context, R.drawable.guangchangphoto));
        photo.setImageBitmap(ImageUtil.toRoundBitmap(context, value.photoimage.get(position).get("photo")));
        images = (ImageView) ViewHolder.get(convertView, R.id.img_datu);
        images.setImageResource(value.picture.get(position).get("picture"));
        name = (TextView) ViewHolder.get(convertView, R.id.guangchangname);
        name.setText(value.name);
        address = (TextView) ViewHolder.get(convertView, R.id.location);
        address.setText(value.address);
        time = (TextView) ViewHolder.get(convertView, R.id.item_time);
        time.setText(value.time);
        titletext = (TextView) ViewHolder.get(convertView, R.id.guangchang_title);
        titletext.setText(value.titlename);
        textcontent = (TextView) ViewHolder.get(convertView, R.id.guangchang_miaoshu);
        textcontent.setText(value.textconent);
        photolist = (HorizontalListView) ViewHolder.get(convertView, R.id.photolist);

        PhotolistInfos photolistInfos = new PhotolistInfos();
        mAdapter = new PhotoListAdapter(context, photolistInfos.imagelist, R.layout.photolistitem);
        photolist.setAdapter(mAdapter);
        return convertView;
    }
}
